<?php
/*
  $Id: gift_cards.php,v 1.0 2007/10/22 by Kasey Drexler $
  Email: kdrexler@dyton.com or x@findyourownjob.com

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

  require('includes/application_top.php');

  if (!tep_session_is_registered('customer_id')) {
    $navigation->set_snapshot();
    tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
  }

  require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_GIFT_CARDS);

  $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_GIFT_CARDS, '', 'SSL'));
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<script language="JavaScript" src="includes/functions.js"></script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="3" cellpadding="3">
  <tr>
    <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2" class="left_nav">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
    </table></td>
<!-- body_text //-->
    <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
            <td class="pageHeading" align="right"><?php //echo tep_image(DIR_WS_IMAGES . 'table_background_account.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
      <tr>
	    <td>
		<?php
		$gift_card_query = tep_db_query("select * from `".TABLE_GIFT_CARDS."` where purchaser='".$_SESSION['customer_id']."' and gift_cards_enabled='1'");
		if (tep_db_num_rows($gift_card_query)>0) {
		  ?>
		  <table cellpadding="0" cellspacing="0" width="100%">
		  <tr>
		    <td class="tableHeading"><?php echo HEADING_GIFT_CARD_INITIAL_AMOUNT; ?></td>
			<td class="tableHeading"><?php echo HEADING_GIFT_CARD_REMAINING_AMOUNT; ?></td>
			<td class="tableHeading"><?php echo HEADING_GIFT_CARD_CODE; ?></td>
			<td class="tableHeading"></td>
		  </tr>
		  <?php
		  while ($gift_card = tep_db_fetch_array($gift_card_query)) {
            echo '<tr>'."\n";
			echo '  <td align="center">'.$gift_card['gift_cards_amount'].'</td>'."\n";
			echo '  <td align="center">'.$gift_card['gift_cards_amount_remaining'].'</td>'."\n";
			echo '  <td align="center">'.$gift_card['gift_cards_code'].'</td>'."\n";
			echo '  <td align="center"><a href="' . tep_href_link(FILENAME_GIFTCARD_EMAIL, 'gcID='.$gift_card['gift_cards_id'], 'SSL') . '">'.TEXT_EMAIL_LINK.'</a></td>'."\n";
			echo '</tr>'."\n";
		  }
		  ?>
		  </table>
		<?php
		} else { 
		?>
		No gift cards found!
		<?php
		}
		?>
		<br /><br />
		<a href="<?php echo tep_href_link(FILENAME_ACCOUNT); ?>">< Go Back</a>
		</td>
	  </tr>
    </table></td>
<!-- body_text_eof //-->
    <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- right_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
<!-- right_navigation_eof //-->
    </table></td>
  </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
